//
//  MeViewController.m
//  MyChatDemo
//
//  Created by DragonYao on 2017/9/11.
//  Copyright © 2017年 DragonYao. All rights reserved.
//

#import "MeViewController.h"
#import "MeInfoCell.h"
#import "XMPPvCardTemp.h"
#import "SLUserInfoController.h"

static NSString *kMeInfoCellId = @"MeInfoCell";

@interface MeViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (weak, nonatomic) IBOutlet UITableView *meTable;

@end

@implementation MeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"我";
    
    [self.meTable registerNib:[UINib nibWithNibName:NSStringFromClass([MeInfoCell class]) bundle:nil] forCellReuseIdentifier:kMeInfoCellId];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    MeInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:kMeInfoCellId];
    //获取名片个人信息
    XMPPvCardTemp *myVCard = [XMPPManager sharedManager].vCartModule.myvCardTemp;
    cell.avartorImgView.image = [UIImage imageWithData:myVCard.photo];
    cell.nicknameLabel.text = [SLUtils isNilString:myVCard.nickname] ? @"默认昵称" : myVCard.nickname;
    cell.userNumberLabel.text = [NSString stringWithFormat:@"微信号：%@", [UserLocalInfo sharedUserInfo].userId];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 78.0;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    SLUserInfoController *userinfo = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:NSStringFromClass([SLUserInfoController class])];
    userinfo.hidesBottomBarWhenPushed = YES;
    [self.navigationController showViewController:userinfo sender:nil];
    
}

//退出登录
- (IBAction)xmppLogout:(UIBarButtonItem *)sender {
    
    [[XMPPManager sharedManager] userLogout];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

@end
